package com.esri.core.geometry;

import com.github.mikephil.charting.utils.Utils;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;

/* loaded from: classes.dex */
class OperatorImportFromWKBCursor extends GeometryCursor {
    ByteBufferCursor a;
    int b;
    int c;
    int d = -1;

    public OperatorImportFromWKBCursor(int i, int i2, ByteBufferCursor byteBufferCursor) {
        if (byteBufferCursor == null) {
            throw new IllegalArgumentException();
        }
        this.b = i;
        this.c = i2;
        this.a = byteBufferCursor;
    }

    @Override // com.esri.core.geometry.GeometryCursor
    public int getGeometryID() {
        return this.d;
    }

    @Override // com.esri.core.geometry.GeometryCursor
    public Geometry next() {
        ByteBuffer next = this.a.next();
        if (next != null) {
            this.d = this.a.getByteBufferID();
            return a(next);
        }
        return null;
    }

    private Geometry a(ByteBuffer byteBuffer) {
        ByteOrder order = byteBuffer.order();
        if (byteBuffer.get(0) == 1) {
            byteBuffer.order(ByteOrder.LITTLE_ENDIAN);
        } else {
            byteBuffer.order(ByteOrder.BIG_ENDIAN);
        }
        int i = byteBuffer.getInt(1);
        try {
            switch (i) {
                case 1:
                    int i2 = this.c;
                    if (i2 != 513 && i2 != 8710 && i2 != 0 && i2 != 3077) {
                        throw new GeometryException("invalid shape type");
                    }
                    return a(false, false, byteBuffer);
                case 2:
                    int i3 = this.c;
                    if (i3 != 25607 && i3 != 0 && i3 != 3077) {
                        throw new GeometryException("invalid shape type");
                    }
                    return a(false, false, false, byteBuffer);
                case 3:
                    int i4 = this.c;
                    if (i4 != 27656 && i4 != 0 && i4 != 3077) {
                        throw new GeometryException("invalid shape type");
                    }
                    return b(false, false, false, byteBuffer);
                case 4:
                    int i5 = this.c;
                    if (i5 != 8710 && i5 != 0 && i5 != 3077) {
                        throw new GeometryException("invalid shape type");
                    }
                    return b(false, false, byteBuffer);
                case 5:
                    int i6 = this.c;
                    if (i6 != 25607 && i6 != 0 && i6 != 3077) {
                        throw new GeometryException("invalid shape type");
                    }
                    return a(true, false, false, byteBuffer);
                case 6:
                    int i7 = this.c;
                    if (i7 != 27656 && i7 != 0 && i7 != 3077) {
                        throw new GeometryException("invalid shape type");
                    }
                    return b(true, false, false, byteBuffer);
                default:
                    switch (i) {
                        case 1001:
                            int i8 = this.c;
                            if (i8 != 513 && i8 != 8710 && i8 != 0 && i8 != 3077) {
                                throw new GeometryException("invalid shape type");
                            }
                            return a(true, false, byteBuffer);
                        case 1002:
                            int i9 = this.c;
                            if (i9 != 25607 && i9 != 0 && i9 != 3077) {
                                throw new GeometryException("invalid shape type");
                            }
                            return a(false, true, false, byteBuffer);
                        case 1003:
                            int i10 = this.c;
                            if (i10 != 27656 && i10 != 0 && i10 != 3077) {
                                throw new GeometryException("invalid shape type");
                            }
                            return b(false, true, false, byteBuffer);
                        case 1004:
                            int i11 = this.c;
                            if (i11 != 8710 && i11 != 0 && i11 != 3077) {
                                throw new GeometryException("invalid shape type");
                            }
                            return b(true, false, byteBuffer);
                        case 1005:
                            int i12 = this.c;
                            if (i12 != 25607 && i12 != 0 && i12 != 3077) {
                                throw new GeometryException("invalid shape type");
                            }
                            return a(true, true, false, byteBuffer);
                        case 1006:
                            int i13 = this.c;
                            if (i13 != 27656 && i13 != 0 && i13 != 3077) {
                                throw new GeometryException("invalid shape type");
                            }
                            return b(true, true, false, byteBuffer);
                        default:
                            switch (i) {
                                case 2001:
                                    int i14 = this.c;
                                    if (i14 != 513 && i14 != 8710 && i14 != 0 && i14 != 3077) {
                                        throw new GeometryException("invalid shape type");
                                    }
                                    return a(false, true, byteBuffer);
                                case 2002:
                                    int i15 = this.c;
                                    if (i15 != 25607 && i15 != 0 && i15 != 3077) {
                                        throw new GeometryException("invalid shape type");
                                    }
                                    return a(false, false, true, byteBuffer);
                                case 2003:
                                    int i16 = this.c;
                                    if (i16 != 27656 && i16 != 0 && i16 != 3077) {
                                        throw new GeometryException("invalid shape type");
                                    }
                                    return b(false, false, true, byteBuffer);
                                case WkbGeometryType.wkbMultiPointM /* 2004 */:
                                    int i17 = this.c;
                                    if (i17 != 8710 && i17 != 0 && i17 != 3077) {
                                        throw new GeometryException("invalid shape type");
                                    }
                                    return b(false, true, byteBuffer);
                                case WkbGeometryType.wkbMultiLineStringM /* 2005 */:
                                    int i18 = this.c;
                                    if (i18 != 25607 && i18 != 0 && i18 != 3077) {
                                        throw new GeometryException("invalid shape type");
                                    }
                                    return a(true, false, true, byteBuffer);
                                case WkbGeometryType.wkbMultiPolygonM /* 2006 */:
                                    int i19 = this.c;
                                    if (i19 != 27656 && i19 != 0 && i19 != 3077) {
                                        throw new GeometryException("invalid shape type");
                                    }
                                    return b(true, false, true, byteBuffer);
                                default:
                                    switch (i) {
                                        case 3001:
                                            int i20 = this.c;
                                            if (i20 != 513 && i20 != 8710 && i20 != 0 && i20 != 3077) {
                                                throw new GeometryException("invalid shape type");
                                            }
                                            return a(true, true, byteBuffer);
                                        case 3002:
                                            int i21 = this.c;
                                            if (i21 != 25607 && i21 != 0 && i21 != 3077) {
                                                throw new GeometryException("invalid shape type");
                                            }
                                            return a(false, true, true, byteBuffer);
                                        case 3003:
                                            int i22 = this.c;
                                            if (i22 != 27656 && i22 != 0 && i22 != 3077) {
                                                throw new GeometryException("invalid shape type");
                                            }
                                            return b(false, true, true, byteBuffer);
                                        case WkbGeometryType.wkbMultiPointZM /* 3004 */:
                                            int i23 = this.c;
                                            if (i23 != 8710 && i23 != 0 && i23 != 3077) {
                                                throw new GeometryException("invalid shape type");
                                            }
                                            return b(true, true, byteBuffer);
                                        case WkbGeometryType.wkbMultiLineStringZM /* 3005 */:
                                            int i24 = this.c;
                                            if (i24 != 25607 && i24 != 0 && i24 != 3077) {
                                                throw new GeometryException("invalid shape type");
                                            }
                                            return a(true, true, true, byteBuffer);
                                        case WkbGeometryType.wkbMultiPolygonZM /* 3006 */:
                                            int i25 = this.c;
                                            if (i25 != 27656 && i25 != 0 && i25 != 3077) {
                                                throw new GeometryException("invalid shape type");
                                            }
                                            return b(true, true, true, byteBuffer);
                                        default:
                                            throw new GeometryException("invalid shape type");
                                    }
                            }
                    }
            }
        } finally {
            byteBuffer.order(order);
        }
    }

    private Geometry a(boolean z, boolean z2, ByteBuffer byteBuffer) {
        int i;
        double d = byteBuffer.getDouble(5);
        double d2 = byteBuffer.getDouble(13);
        double NaN = NumberUtils.NaN();
        int i2 = 21;
        if (z) {
            NaN = byteBuffer.getDouble(21);
            i2 = 29;
        }
        double d3 = NaN;
        double NaN2 = NumberUtils.NaN();
        if (z2) {
            NaN2 = byteBuffer.getDouble(i2);
        }
        double d4 = NaN2;
        int i3 = this.c;
        if (i3 == 3077) {
            Envelope envelope = new Envelope();
            envelope.setCoords(d, d2, d, d2);
            if (z) {
                Envelope1D envelope1D = new Envelope1D();
                envelope1D.vmin = d3;
                envelope1D.vmax = d3;
                envelope.addAttribute(1);
                i = 0;
                envelope.a(1, 0, envelope1D);
            } else {
                i = 0;
            }
            if (z2) {
                Envelope1D envelope1D2 = new Envelope1D();
                envelope1D2.vmin = d4;
                envelope1D2.vmax = d4;
                envelope.addAttribute(2);
                envelope.a(2, i, envelope1D2);
            }
            return envelope;
        } else if (i3 == 8710) {
            boolean isNaN = NumberUtils.isNaN(d);
            MultiPoint multiPoint = new MultiPoint();
            MultiPointImpl multiPointImpl = (MultiPointImpl) multiPoint._getImpl();
            if (!isNaN) {
                AttributeStreamBase createAttributeStreamWithSemantics = AttributeStreamBase.createAttributeStreamWithSemantics(0, 1);
                AttributeStreamOfDbl attributeStreamOfDbl = (AttributeStreamOfDbl) createAttributeStreamWithSemantics;
                attributeStreamOfDbl.write(0, d);
                attributeStreamOfDbl.write(1, d2);
                multiPointImpl.setAttributeStreamRef(0, createAttributeStreamWithSemantics);
                multiPointImpl.resize(1);
            }
            if (z) {
                multiPointImpl.addAttribute(1);
                if (!isNaN && !VertexDescription.isDefaultValue(1, d3)) {
                    AttributeStreamBase createAttributeStreamWithSemantics2 = AttributeStreamBase.createAttributeStreamWithSemantics(1, 1);
                    createAttributeStreamWithSemantics2.writeAsDbl(0, d3);
                    multiPointImpl.setAttributeStreamRef(1, createAttributeStreamWithSemantics2);
                }
            }
            if (z2) {
                multiPointImpl.addAttribute(2);
                if (!isNaN && !VertexDescription.isDefaultValue(2, d4)) {
                    AttributeStreamBase createAttributeStreamWithSemantics3 = AttributeStreamBase.createAttributeStreamWithSemantics(2, 1);
                    createAttributeStreamWithSemantics3.writeAsDbl(0, d4);
                    multiPointImpl.setAttributeStreamRef(2, createAttributeStreamWithSemantics3);
                }
            }
            return multiPoint;
        } else {
            boolean isNaN2 = NumberUtils.isNaN(d);
            Point point = new Point();
            if (!isNaN2) {
                point.setX(d);
                point.setY(d2);
            }
            if (z) {
                point.addAttribute(1);
                if (!isNaN2) {
                    point.setZ(d3);
                }
            }
            if (z2) {
                point.addAttribute(2);
                if (!isNaN2) {
                    point.setM(d4);
                }
            }
            return point;
        }
    }

    /* JADX WARN: Type inference failed for: r14v9 */
    private Geometry b(boolean z, boolean z2, ByteBuffer byteBuffer) {
        MultiPointImpl multiPointImpl;
        AttributeStreamOfDbl attributeStreamOfDbl;
        AttributeStreamOfDbl attributeStreamOfDbl2;
        AttributeStreamOfDbl attributeStreamOfDbl3;
        MultiPoint multiPoint;
        Envelope envelope;
        AttributeStreamOfDbl attributeStreamOfDbl4;
        MultiPointImpl multiPointImpl2;
        Envelope envelope2;
        int i;
        AttributeStreamOfDbl attributeStreamOfDbl5;
        int i2;
        MultiPointImpl multiPointImpl3;
        int i3 = byteBuffer.getInt(5);
        double doubleMax = NumberUtils.doubleMax();
        double d = -NumberUtils.doubleMax();
        int i4 = this.c;
        if (i4 == 8710 || i4 == 0) {
            MultiPoint multiPoint2 = new MultiPoint();
            MultiPointImpl multiPointImpl4 = (MultiPointImpl) multiPoint2._getImpl();
            if (i3 > 0) {
                Envelope envelope3 = new Envelope();
                multiPointImpl4.resize(i3);
                AttributeStreamOfDbl attributeStreamOfDbl6 = (AttributeStreamOfDbl) AttributeStreamBase.createAttributeStreamWithSemantics(0, i3);
                if (z) {
                    attributeStreamOfDbl4 = (AttributeStreamOfDbl) AttributeStreamBase.createAttributeStreamWithSemantics(1, i3);
                    envelope3.addAttribute(1);
                } else {
                    attributeStreamOfDbl4 = null;
                }
                if (z2) {
                    envelope3.addAttribute(2);
                    attributeStreamOfDbl3 = attributeStreamOfDbl6;
                    attributeStreamOfDbl2 = attributeStreamOfDbl4;
                    attributeStreamOfDbl = (AttributeStreamOfDbl) AttributeStreamBase.createAttributeStreamWithSemantics(2, i3);
                } else {
                    attributeStreamOfDbl3 = attributeStreamOfDbl6;
                    attributeStreamOfDbl2 = attributeStreamOfDbl4;
                    attributeStreamOfDbl = null;
                }
                multiPoint = multiPoint2;
                envelope = envelope3;
                multiPointImpl = multiPointImpl4;
            } else {
                multiPointImpl = multiPointImpl4;
                attributeStreamOfDbl = null;
                attributeStreamOfDbl2 = null;
                attributeStreamOfDbl3 = null;
                multiPoint = multiPoint2;
                envelope = null;
            }
        } else {
            envelope = new Envelope();
            if (z) {
                envelope.addAttribute(1);
            }
            if (z2) {
                envelope.addAttribute(2);
            }
            attributeStreamOfDbl = null;
            attributeStreamOfDbl2 = null;
            attributeStreamOfDbl3 = null;
            multiPoint = null;
            multiPointImpl = null;
        }
        double d2 = doubleMax;
        double d3 = d2;
        double d4 = d;
        double d5 = d4;
        double d6 = d5;
        double d7 = d6;
        int i5 = 0;
        int i6 = 9;
        boolean z3 = false;
        boolean z4 = false;
        double d8 = d3;
        while (i5 < i3) {
            int i7 = i6 + 5;
            int i8 = i3;
            double d9 = byteBuffer.getDouble(i7);
            int i9 = i7 + 8;
            MultiPoint multiPoint3 = multiPoint;
            MultiPointImpl multiPointImpl5 = multiPointImpl;
            double d10 = byteBuffer.getDouble(i9);
            int i10 = i9 + 8;
            Envelope envelope4 = envelope;
            int i11 = this.c;
            double d11 = d8;
            if (i11 == 8710 || i11 == 0) {
                int i12 = i5 * 2;
                attributeStreamOfDbl3.write(i12, d9);
                attributeStreamOfDbl3.write(i12 + 1, d10);
            }
            if (d9 < d2) {
                d2 = d9;
            }
            if (d9 > d5) {
                d5 = d9;
            }
            if (d10 < d3) {
                d3 = d10;
            }
            if (d10 > d7) {
                d7 = d10;
            }
            if (z) {
                double translateFromAVNaN = Interop.translateFromAVNaN(byteBuffer.getDouble(i10));
                i10 += 8;
                int i13 = this.c;
                if (i13 == 8710 || i13 == 0) {
                    attributeStreamOfDbl2.write(i5, translateFromAVNaN);
                    if (!VertexDescription.isDefaultValue(1, translateFromAVNaN)) {
                        z3 = true;
                    }
                }
                if (translateFromAVNaN < doubleMax) {
                    doubleMax = translateFromAVNaN;
                }
                double d12 = d6;
                d6 = translateFromAVNaN > d12 ? translateFromAVNaN : d12;
            }
            if (z2) {
                double translateFromAVNaN2 = Interop.translateFromAVNaN(byteBuffer.getDouble(i10));
                i10 += 8;
                int i14 = this.c;
                if (i14 == 8710 || i14 == 0) {
                    attributeStreamOfDbl.write(i5, translateFromAVNaN2);
                    if (!VertexDescription.isDefaultValue(2, translateFromAVNaN2)) {
                        z4 = true;
                    }
                }
                d8 = translateFromAVNaN2 < d11 ? translateFromAVNaN2 : d11;
                if (translateFromAVNaN2 > d4) {
                    d4 = translateFromAVNaN2;
                }
            } else {
                d8 = d11;
            }
            i5++;
            i6 = i10;
            i3 = i8;
            multiPoint = multiPoint3;
            multiPointImpl = multiPointImpl5;
            envelope = envelope4;
        }
        int i15 = i3;
        Envelope envelope5 = envelope;
        MultiPoint multiPoint4 = multiPoint;
        MultiPointImpl multiPointImpl6 = multiPointImpl;
        double d13 = d6;
        if (i15 > 0) {
            int i16 = this.c;
            if (i16 == 8710 || i16 == 0) {
                multiPointImpl3 = multiPointImpl6;
                multiPointImpl3.setAttributeStreamRef(0, attributeStreamOfDbl3);
            } else {
                multiPointImpl3 = multiPointImpl6;
            }
            envelope5.setCoords(d2, d3, d5, d7);
            multiPointImpl2 = multiPointImpl3;
        } else {
            multiPointImpl2 = multiPointImpl6;
        }
        if (z) {
            int i17 = this.c;
            if (i17 == 8710 || i17 == 0) {
                i = 1;
                multiPointImpl2.addAttribute(1);
                if (i15 > 0) {
                    if (!z3) {
                        attributeStreamOfDbl2 = null;
                    }
                    multiPointImpl2.setAttributeStreamRef(1, attributeStreamOfDbl2);
                }
            } else {
                i = 1;
            }
            if (i15 > 0) {
                Envelope1D envelope1D = new Envelope1D();
                envelope1D.setCoords(doubleMax, d13);
                envelope2 = envelope5;
                envelope2.a(i, 0, envelope1D);
            } else {
                envelope2 = envelope5;
            }
        } else {
            envelope2 = envelope5;
            i = 1;
        }
        if (z2) {
            int i18 = this.c;
            if (i18 == 8710 || i18 == 0) {
                multiPointImpl2.addAttribute(i);
                if (i15 > 0) {
                    if (z4) {
                        attributeStreamOfDbl5 = attributeStreamOfDbl;
                        i2 = 2;
                    } else {
                        i2 = 2;
                        attributeStreamOfDbl5 = null;
                    }
                    multiPointImpl2.setAttributeStreamRef(i2, attributeStreamOfDbl5);
                }
            }
            if (i15 > 0) {
                Envelope1D envelope1D2 = new Envelope1D();
                envelope1D2.setCoords(doubleMax, d13);
                envelope2.a(1, 0, envelope1D2);
            }
        }
        if (this.c == 3077) {
            return envelope2;
        }
        if (i15 > 0) {
            multiPointImpl2.setEnvelope(envelope2);
        }
        return multiPoint4;
    }

    /* JADX WARN: Removed duplicated region for block: B:128:0x0294  */
    /* JADX WARN: Removed duplicated region for block: B:140:0x02be A[RETURN] */
    /* JADX WARN: Removed duplicated region for block: B:141:0x02bf  */
    /* JADX WARN: Type inference failed for: r1v5 */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct code enable 'Show inconsistent code' option in preferences
    */
    private com.esri.core.geometry.Geometry a(boolean r46, boolean r47, boolean r48, java.nio.ByteBuffer r49) {
        /*
            Method dump skipped, instructions count: 709
            To view this dump change 'Code comments level' option to 'DEBUG'
        */
        throw new UnsupportedOperationException("Method not decompiled: com.esri.core.geometry.OperatorImportFromWKBCursor.a(boolean, boolean, boolean, java.nio.ByteBuffer):com.esri.core.geometry.Geometry");
    }

    private Geometry b(boolean z, boolean z2, boolean z3, ByteBuffer byteBuffer) {
        int i;
        int i2;
        int i3;
        Polygon polygon;
        Envelope envelope;
        AttributeStreamOfInt32 attributeStreamOfInt32;
        AttributeStreamOfInt8 attributeStreamOfInt8;
        AttributeStreamOfDbl attributeStreamOfDbl;
        AttributeStreamOfDbl attributeStreamOfDbl2;
        AttributeStreamOfDbl attributeStreamOfDbl3;
        MultiPathImpl multiPathImpl;
        AttributeStreamOfDbl attributeStreamOfDbl4;
        AttributeStreamOfInt8 attributeStreamOfInt82;
        AttributeStreamOfDbl attributeStreamOfDbl5;
        AttributeStreamOfDbl attributeStreamOfDbl6;
        double d;
        double d2;
        double d3;
        double d4;
        double d5;
        double d6;
        AttributeStreamOfDbl attributeStreamOfDbl7;
        boolean z4;
        boolean z5;
        double d7;
        Polygon polygon2;
        int i4;
        int i5;
        int i6;
        int i7;
        AttributeStreamOfInt8 attributeStreamOfInt83;
        int i8;
        AttributeStreamOfDbl attributeStreamOfDbl8;
        AttributeStreamOfDbl attributeStreamOfDbl9;
        AttributeStreamOfDbl attributeStreamOfDbl10;
        AttributeStreamOfDbl attributeStreamOfDbl11;
        AttributeStreamOfDbl attributeStreamOfDbl12;
        int i9;
        AttributeStreamOfDbl attributeStreamOfDbl13;
        ByteBuffer byteBuffer2 = byteBuffer;
        int i10 = 5;
        if (z) {
            i = byteBuffer2.getInt(5);
            i2 = 9;
        } else {
            i = 1;
            i2 = 0;
        }
        double doubleMax = NumberUtils.doubleMax();
        double d8 = -NumberUtils.doubleMax();
        int i11 = i2;
        int i12 = 0;
        int i13 = 0;
        int i14 = 0;
        while (true) {
            i3 = 4;
            if (i12 >= i) {
                break;
            }
            int i15 = i11 + i10;
            int i16 = byteBuffer2.getInt(i15);
            i11 = i15 + 4;
            for (int i17 = 0; i17 < i16; i17++) {
                int i18 = byteBuffer2.getInt(i11);
                i11 += 4;
                if (i18 != 0) {
                    i13 += i18;
                    i14++;
                    i11 += i18 * 2 * 8;
                    if (z2) {
                        i11 += i18 * 8;
                    }
                    if (z3) {
                        i11 += i18 * 8;
                    }
                }
            }
            i12++;
            i10 = 5;
        }
        int i19 = i13 - i14;
        int i20 = this.c;
        if (i20 == 27656 || i20 == 0) {
            Polygon polygon3 = new Polygon();
            MultiPathImpl multiPathImpl2 = (MultiPathImpl) polygon3._getImpl();
            if (i19 > 0) {
                Envelope envelope2 = new Envelope();
                attributeStreamOfInt32 = (AttributeStreamOfInt32) AttributeStreamBase.createIndexStream(i14 + 1);
                attributeStreamOfInt32.write(0, 0);
                AttributeStreamOfInt8 attributeStreamOfInt84 = (AttributeStreamOfInt8) AttributeStreamBase.createByteStream(attributeStreamOfInt32.size());
                AttributeStreamOfDbl attributeStreamOfDbl14 = (AttributeStreamOfDbl) AttributeStreamBase.createAttributeStreamWithSemantics(0, i19);
                if (z2) {
                    attributeStreamOfDbl4 = (AttributeStreamOfDbl) AttributeStreamBase.createAttributeStreamWithSemantics(1, i19);
                    envelope2.addAttribute(1);
                } else {
                    attributeStreamOfDbl4 = null;
                }
                if (z3) {
                    envelope2.addAttribute(2);
                    multiPathImpl = multiPathImpl2;
                    attributeStreamOfInt8 = attributeStreamOfInt84;
                    attributeStreamOfDbl = attributeStreamOfDbl14;
                    attributeStreamOfDbl2 = attributeStreamOfDbl4;
                    attributeStreamOfDbl3 = (AttributeStreamOfDbl) AttributeStreamBase.createAttributeStreamWithSemantics(2, i19);
                } else {
                    attributeStreamOfDbl3 = null;
                    multiPathImpl = multiPathImpl2;
                    attributeStreamOfInt8 = attributeStreamOfInt84;
                    attributeStreamOfDbl = attributeStreamOfDbl14;
                    attributeStreamOfDbl2 = attributeStreamOfDbl4;
                }
                polygon = polygon3;
                envelope = envelope2;
            } else {
                polygon = polygon3;
                envelope = null;
                attributeStreamOfInt32 = null;
                attributeStreamOfInt8 = null;
                attributeStreamOfDbl = null;
                attributeStreamOfDbl2 = null;
                attributeStreamOfDbl3 = null;
                multiPathImpl = multiPathImpl2;
            }
        } else {
            envelope = new Envelope();
            if (z2) {
                envelope.addAttribute(1);
            }
            if (z3) {
                envelope.addAttribute(2);
            }
            multiPathImpl = null;
            polygon = null;
            attributeStreamOfInt32 = null;
            attributeStreamOfInt8 = null;
            attributeStreamOfDbl = null;
            attributeStreamOfDbl2 = null;
            attributeStreamOfDbl3 = null;
        }
        if (i19 > 0) {
            double d9 = doubleMax;
            double d10 = d9;
            double d11 = d8;
            double d12 = d11;
            double d13 = d12;
            double d14 = d13;
            int i21 = 0;
            int i22 = 0;
            z4 = false;
            z5 = false;
            int i23 = 0;
            double d15 = d10;
            while (i21 < i) {
                int i24 = i2 + 5;
                int i25 = byteBuffer2.getInt(i24);
                i2 = i24 + i3;
                int i26 = i22;
                int i27 = i;
                int i28 = i26 + i25;
                boolean z6 = z4;
                double d16 = doubleMax;
                int i29 = i26;
                int i30 = i23;
                boolean z7 = z5;
                double d17 = d16;
                while (i29 < i28) {
                    int i31 = byteBuffer2.getInt(i2);
                    i2 += 4;
                    if (i31 == 0) {
                        i6 = i28;
                        i7 = i30;
                        attributeStreamOfInt83 = attributeStreamOfInt8;
                        i8 = i26;
                        attributeStreamOfDbl8 = attributeStreamOfDbl;
                        attributeStreamOfDbl9 = attributeStreamOfDbl2;
                        attributeStreamOfDbl10 = attributeStreamOfDbl3;
                    } else {
                        i6 = i28;
                        int i32 = (i30 + i31) - 1;
                        double d18 = d15;
                        int i33 = this.c;
                        if (i33 == 27656 || i33 == 0) {
                            if (i29 == i26) {
                                attributeStreamOfInt8.setBits(i29, (byte) 4);
                            }
                            attributeStreamOfInt8.setBits(i29, (byte) 1);
                            attributeStreamOfInt32.write(i29 + 1, i32);
                        }
                        i2 += 16;
                        if (z2) {
                            i2 += 8;
                        }
                        if (z3) {
                            i2 += 8;
                        }
                        int i34 = i32 - 1;
                        while (i34 >= i30) {
                            int i35 = i34;
                            double d19 = byteBuffer2.getDouble(i2);
                            int i36 = i2 + 8;
                            AttributeStreamOfInt8 attributeStreamOfInt85 = attributeStreamOfInt8;
                            int i37 = i26;
                            double d20 = byteBuffer2.getDouble(i36);
                            i2 = i36 + 8;
                            int i38 = i32;
                            int i39 = this.c;
                            int i40 = i30;
                            if (i39 == 27656 || i39 == 0) {
                                int i41 = i35 * 2;
                                attributeStreamOfDbl11 = attributeStreamOfDbl;
                                attributeStreamOfDbl11.write(i41, d19);
                                attributeStreamOfDbl11.write(i41 + 1, d20);
                            } else {
                                attributeStreamOfDbl11 = attributeStreamOfDbl;
                            }
                            if (d19 < d17) {
                                d17 = d19;
                            }
                            if (d19 > d12) {
                                d12 = d19;
                            }
                            if (d20 < d18) {
                                d18 = d20;
                            }
                            if (d20 > d11) {
                                d11 = d20;
                            }
                            if (z2) {
                                double d21 = byteBuffer2.getDouble(i2);
                                i2 += 8;
                                int i42 = this.c;
                                if (i42 == 27656 || i42 == 0) {
                                    attributeStreamOfDbl12 = attributeStreamOfDbl2;
                                    i9 = i35;
                                    attributeStreamOfDbl12.write(i9, d21);
                                    if (!VertexDescription.isDefaultValue(1, d21)) {
                                        z6 = true;
                                    }
                                } else {
                                    attributeStreamOfDbl12 = attributeStreamOfDbl2;
                                    i9 = i35;
                                }
                                if (d21 < d9) {
                                    d9 = d21;
                                }
                                if (d21 > d13) {
                                    d13 = d21;
                                }
                            } else {
                                attributeStreamOfDbl12 = attributeStreamOfDbl2;
                                i9 = i35;
                            }
                            if (z3) {
                                double d22 = byteBuffer2.getDouble(i2);
                                i2 += 8;
                                int i43 = this.c;
                                if (i43 == 27656 || i43 == 0) {
                                    attributeStreamOfDbl13 = attributeStreamOfDbl3;
                                    attributeStreamOfDbl13.write(i9, d22);
                                    if (!VertexDescription.isDefaultValue(2, d22)) {
                                        z7 = true;
                                    }
                                } else {
                                    attributeStreamOfDbl13 = attributeStreamOfDbl3;
                                }
                                if (d22 < d10) {
                                    d10 = d22;
                                }
                                if (d22 > d14) {
                                    d14 = d22;
                                }
                            } else {
                                attributeStreamOfDbl13 = attributeStreamOfDbl3;
                            }
                            i34 = i9 - 1;
                            attributeStreamOfDbl3 = attributeStreamOfDbl13;
                            attributeStreamOfDbl2 = attributeStreamOfDbl12;
                            attributeStreamOfDbl = attributeStreamOfDbl11;
                            attributeStreamOfInt8 = attributeStreamOfInt85;
                            i26 = i37;
                            i32 = i38;
                            i30 = i40;
                            byteBuffer2 = byteBuffer;
                        }
                        i7 = i32;
                        attributeStreamOfInt83 = attributeStreamOfInt8;
                        i8 = i26;
                        attributeStreamOfDbl8 = attributeStreamOfDbl;
                        attributeStreamOfDbl9 = attributeStreamOfDbl2;
                        attributeStreamOfDbl10 = attributeStreamOfDbl3;
                        d15 = d18;
                    }
                    i29++;
                    attributeStreamOfDbl3 = attributeStreamOfDbl10;
                    attributeStreamOfDbl2 = attributeStreamOfDbl9;
                    attributeStreamOfDbl = attributeStreamOfDbl8;
                    i28 = i6;
                    attributeStreamOfInt8 = attributeStreamOfInt83;
                    i26 = i8;
                    i30 = i7;
                    byteBuffer2 = byteBuffer;
                }
                int i44 = i28;
                i21++;
                i = i27;
                doubleMax = d17;
                z5 = z7;
                z4 = z6;
                i22 = i44;
                i23 = i30;
                i3 = 4;
                byteBuffer2 = byteBuffer;
            }
            attributeStreamOfInt82 = attributeStreamOfInt8;
            attributeStreamOfDbl5 = attributeStreamOfDbl;
            attributeStreamOfDbl6 = attributeStreamOfDbl3;
            d4 = d13;
            d3 = d14;
            attributeStreamOfDbl7 = attributeStreamOfDbl2;
            d6 = d11;
            d5 = d12;
            d = doubleMax;
            d2 = d15;
            doubleMax = d9;
            d7 = d10;
        } else {
            attributeStreamOfInt82 = attributeStreamOfInt8;
            attributeStreamOfDbl5 = attributeStreamOfDbl;
            attributeStreamOfDbl6 = attributeStreamOfDbl3;
            d = doubleMax;
            d2 = d;
            d3 = d8;
            d4 = d3;
            d5 = d4;
            d6 = d5;
            attributeStreamOfDbl7 = attributeStreamOfDbl2;
            z4 = false;
            z5 = false;
            d7 = d2;
        }
        AttributeStreamOfDbl attributeStreamOfDbl15 = attributeStreamOfDbl6;
        if (i19 > 0) {
            int i45 = this.c;
            polygon2 = polygon;
            if (i45 == 27656 || i45 == 0) {
                multiPathImpl.setPathStreamRef(attributeStreamOfInt32);
                multiPathImpl.setPathFlagsStreamRef(attributeStreamOfInt82);
                multiPathImpl.setAttributeStreamRef(0, attributeStreamOfDbl5);
            }
            envelope.setCoords(d, d2, d5, d6);
        } else {
            polygon2 = polygon;
        }
        if (z2) {
            int i46 = this.c;
            if (i46 == 27656 || i46 == 0) {
                i5 = 1;
                multiPathImpl.addAttribute(1);
                if (i19 > 0) {
                    multiPathImpl.setAttributeStreamRef(1, !z4 ? null : attributeStreamOfDbl7);
                }
            } else {
                i5 = 1;
            }
            if (i19 > 0) {
                Envelope1D envelope1D = new Envelope1D();
                envelope1D.setCoords(doubleMax, d4);
                envelope.a(i5, 0, envelope1D);
            }
        }
        if (z3) {
            int i47 = this.c;
            if (i47 == 27656 || i47 == 0) {
                i4 = 2;
                multiPathImpl.addAttribute(2);
                if (i19 > 0) {
                    multiPathImpl.setAttributeStreamRef(2, !z5 ? null : attributeStreamOfDbl15);
                }
            } else {
                i4 = 2;
            }
            if (i19 > 0) {
                Envelope1D envelope1D2 = new Envelope1D();
                envelope1D2.setCoords(d7, d3);
                envelope.a(i4, 0, envelope1D2);
            }
        }
        if (this.c == 3077) {
            return envelope;
        }
        if (i19 > 0) {
            multiPathImpl.setEnvelope(envelope);
        }
        if ((this.b & 2) == 0) {
            multiPathImpl.a(1, Utils.DOUBLE_EPSILON);
        }
        multiPathImpl.setDirtyOGCFlags(false);
        return polygon2;
    }
}
